package com.alumni_circle.core.security;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 龙小虬
 * @since 2020-08-14 18:44
 */
@Component
public class TokenInvalidHandler {

    public void token(HttpServletResponse response) throws IOException {
        Map<String,String> result = new HashMap<>();
        result.put("信息错误","403");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json;charset=utf-8");
        PrintWriter printWriter = response.getWriter();
        System.out.println(result.toString());
        JSON json = JSONUtil.parse(result);
        printWriter.write(json.toString());
    }
}
